﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XStudio.XCRF.Data.Enums;
using XStudio.XCRF.Resources.Enums;

namespace XStudio.XCRF.Web.Models.Enums
{
    public class TongueShapeTypeInfo
    {
        /// <summary>
        /// 形状
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 对应键值
        /// </summary>
        public byte? Value { get; set; }

        public static string GetName(byte pulse)
        {
            string key = ((TongueShapeTypes)pulse).ToString();
            return TongueShapeResource.ResourceManager.GetString(key);
        }

        public static IEnumerable<SelectListItem> SelectListItems
        {
            get
            {
                List<SelectListItem> items = new List<SelectListItem>();
                string[] typeNames = Enum.GetNames(typeof(TongueShapeTypes));
                //items.Add(new SelectListItem
                //{
                //    Text = "",
                //    Value = ""
                //});
                foreach (string typeName in typeNames)
                {
                    TongueShapeTypes type = (TongueShapeTypes)Enum.Parse(typeof(TongueShapeTypes), typeName);
                    string name = TongueShapeResource.ResourceManager.GetString(typeName);
                    items.Add(new SelectListItem
                    {
                        Text = name,
                        Value = ((byte)type).ToString()
                    });
                }
                return items;
            }
        }
    }
}
